package com.shxzz.shortlink.admin.common.biz.user;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * @author shxzz
 * @create 2023-12-13-15:50
 * @description 用户上下文信息
 */
public class UserContext {
    /**
     * 当前用户信息
     */
    private static final ThreadLocal<UserInfoDTO> USER_THREAD_LOCAL = new TransmittableThreadLocal<>();

    public static void setUser(UserInfoDTO user) {
        USER_THREAD_LOCAL.set(user);
    }

    public static UserInfoDTO getUser() {
        return USER_THREAD_LOCAL.get();
    }

    public static void removeUser() {
        USER_THREAD_LOCAL.remove();
    }
}
